import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    meta: {
      title: "布局",
      hidden: true
    },
    redirect: 'newsList',
    component: () => import('../components/Layout/index'),
    children: [
      {
        path: 'newsList',
        name: 'newsList',
        meta: {
          title: "新闻列表",
          icon: require('@/assets/NavBar-icon/list.png'),
          iconSel: require('@/assets/NavBar-icon/list(1).png')
        },
        component: () => import('../views/newsList.vue')
      },
      {
        path: 'newsType',
        name: 'newsType',
        meta: {
          title: "新闻分类",
          icon: require('@/assets/NavBar-icon/type.png'),
          iconSel: require('@/assets/NavBar-icon/type(1).png')
        },
        component: () => import('../views/newsType.vue')
      },
      {
        path: 'users',
        name: 'users',
        meta: {
          title: "用户管理",
          icon: require('@/assets/NavBar-icon/user.png'),
          iconSel: require('@/assets/NavBar-icon/user(1).png')
        },
        component: () => import('../views/users.vue')
      },
      {
        path: 'swiperMgr',
        name: 'swiperMgr',
        meta: {
          title: "轮播管理",
          icon: require('@/assets/NavBar-icon/swi.png'),
          iconSel: require('@/assets/NavBar-icon/swi(1).png')
        },
        component: () => import('../views/swiperMgr.vue')
      },
      {
        path: 'person',
        name: 'person',
        meta: {
          title: "员工管理",
          icon: require('@/assets/NavBar-icon/person.png'),
          iconSel: require('@/assets/NavBar-icon/person(1).png')
        },
        component: () => import('../views/person.vue')
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: "登录",
      hidden: true
    },
    component: () => import('../views/login.vue')
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  document.title = '龚飞飞的' + to.meta.title;
  next();
})

export default router
